package com.quanyue.music.user.mapper;

import com.quanyue.music.domain.entity.FmVip;
import com.quanyue.music.user.type.FmVipDetail;
import com.shzisg.mybatis.mapper.auto.AutoMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface VIPMapper extends AutoMapper <FmVip> {

    FmVip findByUserIdValid(@Param("userId") String userId);

    @Select("select v.id from qy_fm_vip v where v.user_id = #{userId} and v.del_flag = 1")
    String findExpiredUser(@Param("userId") String userId);

    @Select("select v.*, u.open_id from qy_fm_vip v left join qy_user u on v.user_id = u.id")
    List <FmVipDetail> findAllDetail();

    @Select("select v.*, u.open_id from qy_fm_vip v left join qy_user u on v.user_id = u.id where v.user_id = #{userId}")
    List <FmVipDetail> findByUserId(@Param("userId") String userId);
}
